// shader.frag
#version 330 core

uniform vec3      iResolution;
uniform float     iTime;
uniform float     iTimeDelta;
uniform int       iFrame;

in vec2 fragCoord;
out vec4 fragColor;

void main() {
    vec2 uv = fragCoord;
    uv -= 0.5;
    uv /= vec2(iResolution.xy) / iResolution.y;

    float t = iTime * 0.5;
    vec2 p = uv;
    float a = t;
    mat2 r = mat2(cos(a), -sin(a), sin(a), cos(a));
    p *= r;

    p = 0.8 * p / length(p) * (1.0 + 0.2 * cos(6.0 * atan(p.y, p.x) + 3.0 * t));
    p += 0.4 * cos(p.yx * 4.0 + vec2(0.0, 2.0) + t);

    float z = 0.5 + 0.5 * cos(length(p) * 4.0 - t);

    vec3 col = 0.5 + 0.5 * cos(vec3(0.0, 1.0, 2.0) + z + vec3(0.0, 0.5, 1.0));
    col *= 1.0 - 0.5 * length(uv);

    fragColor = vec4(col, 1.0);
}

